<%@ include file="/WEB-INF/jsp/common/includes.jsp" %>
<%@ include file="/WEB-INF/jsp/common/header.jsp" %>
<c:choose>
    <c:when test="${pet.new}"><c:set var="method" value="post"/></c:when>
    <c:otherwise><c:set var="method" value="put"/></c:otherwise>
</c:choose>

<b>Edit: ${pet.id} - ${pet.name}</b>

<form:form modelAttribute="pet" method="${method}">
    <table>
        <tr>
            <th>
                Name:${sessionScope.pet.id} <form:errors path="name" cssClass="errors"/>
                <br/>
                <form:input path="name" size="30" maxlength="30"/>
            </th>
        </tr>
        <tr>
            <th>
                Birth Date: <form:errors path="birth_date" cssClass="errors"/>
                <br/>
                <form:input path="birth_date" size="10" maxlength="10"/> (yyyy-mm-dd)
            </th>
        </tr>
        <tr>
            <th>
                Type: <form:errors path="type" cssClass="errors"/>
                <br/>
                <form:select path="type" items="${types}"/>
            </th>
        </tr>
        <tr>
            <td>
                <c:choose>
                    <c:when test="${pet.new}">
                        <p class="submit"><input type="submit" value="Add Pet"/></p>
                    </c:when>
                    <c:otherwise>
                        <p class="submit"><input type="submit" value="Update Pet"/></p>
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
    </table>
</form:form>
</table>

<c:if test="${!pet.new}">
  <form:form method="delete">
    <p class="submit"><input type="submit" value="Delete Pet"/></p>
  </form:form>
</c:if>
<%@ include file="/WEB-INF/jsp/common/footer.jsp" %>